home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4148 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.6 KB

  1. Path: diku.dk!null
  2. From: null@diku.dk (Niels Ull Jacobsen)
  3. Newsgroups: comp.os.ms-windows.programmer.tools.mfc,comp.os.ms-windows.apps.compatibility.win95,comp.lang.c++
  4. Subject: Re: HELP - CString conversion?
  5. Date: 28 Jan 1996 11:54:06 GMT
  6. Organization: Department of Computer Science, U of Copenhagen
  7. Sender: null@tyr.diku.dk
  8. Message-ID: <4efo4u$2ve@odin.diku.dk>
  9. References: <NEWTNews.16531.822443361.Postmaster@Jerusalem.netvision.net.il> <4ea0gm$eka@basfigw.basf-corp.com>
  10. NNTP-Posting-Host: odin.diku.dk
  11. X-Newsreader: NN version 6.5.0 #13
  12.  
  13. Adler <Andreas.Adler@zxa.x400.basf-ag.de> writes:
  14.  
  15. >iti@Jerusalem.netvision.net.il wrote:
  16. >>
  17. >>When I try to read the text from a Edit Control (IDC_EDIT1) with the
  18. >>following code:
  19. >>
  20. >>--------------------------------------------------------------
  21. >>CString callBuf;
  22. >>int msgLen = GetDlgItemText(IDC_EDIT1, callBuf, sizeof(callBuf));
  23. >>--------------------------------------------------------------
  24. >>
  25. >>I get the following error:
  26. >>
  27. >>--------------------------------------------------------------
  28. >>error C2664: 'GetDlgItemText' : cannot convert parameter 2 from 'class >::CString ' to 'char __far *'
  29. >>--------------------------------------------------------------
  30.  
  31. >try:
  32. > #define MAXLEN 256 
  33. > CString callBuf;
  34. > LPTSTR p;
  35. > int msgLen;
  36.  
  37. > p=callBuf.GetBuffer(MAXLEN);
  38. > msgLen = GetDlgItemText(IDC_EDIT1, p, MAXLEN);
  39. > callBuf.ReleaseBuffer();
  40.  
  41. Totally correct. Of course, you could just use the somewhat simpler
  42.  
  43. msgLen = GetDlgItemText(IDC_EDIT1, callBuf);
  44.  
  45.  
  46.  
  47.  
  48.  
  49. >Andreas Adler
  50.  
  51.  
  52. -- 
  53.    Niels Ull Jacobsen, Dep. of CS, U of Copenhagen (null@diku.dk)
  54.    Roenne Alle 3 st.th, 2860 Soeborg, Denmark, tel. +45 39 66 39 86
  55.  
  56.